const CracoLessPlugin = require("craco-less");
const getCSSModuleLocalIdent = require("react-dev-utils/getCSSModuleLocalIdent");

module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: {},
            javascriptEnabled: true,
          },
        },
      },
    },
    {
      plugin: CracoLessPlugin,
      options: {
        modifyLessRule(lessRule, _context) {
          return Object.assign({}, lessRule, {
            test: /\.(module)\.(less)$/,
            exclude: /node_modules/,
            sideEffects: true,
          });
        },
        lessLoaderOptions: {
          lessOptions: {
            javascriptEnabled: true,
          },
        },
        cssLoaderOptions: {
          modules: {
            getLocalIdent: getCSSModuleLocalIdent,
          },
        },
      },
    },
  ],
};
